gnttab: fix transitive grant handling
authorJan Beulich <jbeulich@suse.com>
Thu, 17 Aug 2017 12:40:31 +0000 (14:40 +0200)
committerJan Beulich <jbeulich@suse.com>
Thu, 17 Aug 2017 12:40:31 +0000 (14:40 +0200)
commitad48fb963dbff02762d2db5396fa655ac0c432c7
tree1ef600fa22f0baf23b31e40c6f488b0bdf85f164
parent999d2ccb7f73408aa22656e1ba2f98b077eaa1c2
gnttab: fix transitive grant handling

Processing of transitive grants must not use the fast path, or else
reference counting breaks due to the skipped recursive call to
__acquire_grant_for_copy() (its __release_grant_for_copy()
counterpart occurs independent of original pin count). Furthermore
after re-acquiring temporarily dropped locks we need to verify no grant
properties changed if the original pin count was non-zero; checking
just the pin counts is sufficient only for well-behaved guests. As a
result, __release_grant_for_copy() needs to mirror that new behavior.

Furthermore a __release_grant_for_copy() invocation was missing on the
retry path of __acquire_grant_for_copy(), and gnttab_set_version() also
needs to bail out upon encountering a transitive grant.

This is part of XSA-226.

Reported-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
xen/common/grant_table.c